home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / jjbqc.zip / JJBKBD.H < prev    next >
C/C++ Source or Header  |  1993-01-04  |  9KB  |  154 lines

  1.  
  2.  
  3.  
  4. /****************************************************************************
  5.  *                                                                          *
  6.  *                               jjbkbd.h                                   *
  7.  *                                                                          *
  8.  *   Copyright (c) 1989, JJB. All rights reserved.                          *
  9.  *                                                                          *
  10.  *   Purpose:                                                               *
  11.  *                                                                          *
  12.  *      The purpose of this file is to make definitions for the keyboard    *
  13.  *      and to explain to you how important the get_ch() function is        *
  14.  *      and why it is considered to be at the heart of the entire JJB       *
  15.  *      programming environment.                                            *
  16.  *                                                                          *
  17.  *                                                                          *
  18.  *     JJB, 9236 church Rd suite 1082, Dallas, Tx 75231 (214) 341-1635      *
  19.  ****************************************************************************/
  20.  
  21. #ifndef BL
  22.  
  23. #define BL   32
  24. #define RET  '\015'
  25. #define AST  '\052'
  26. #define ESC  '\033'
  27. #define BSPC '\010'
  28.  
  29. /****************************************************************************
  30.  *                                                                          *
  31.  *           get_ch()      get_num()     get_any();                         *
  32.  *                                                                          *
  33.  *  If you have the printed documentation of JJB, you can see how there are *
  34.  *  5 low level functions you can use below the function get_ch() and 3     *
  35.  *  higher level functions above it which give you absolute control over    *
  36.  *  keyboard.                                                               *
  37.  *                                                                          *
  38.  *  The printed documentation also explains how you can define a string     *
  39.  *  of characters which get_ch() will read thinking it is coming from       *
  40.  *  the keyboard instead of from the user of your program.                  *
  41.  *                                                                          *
  42.  *      char get_ch();   wait for alphanumberic or function keypress        *
  43.  *      char get_num();  wait for numeric or function keypress              *
  44.  *      char get_any();  wait for any key to be pressed                     *
  45.  *                                                                          *
  46.  ****************************************************************************/
  47.  
  48. #define SPACEBAR_PRESSED    (get(IKE) == 32)
  49. #define ESC_PRESSED         (getc(KE) == ESC)
  50. #define F1_PRESSED          (!get(IKE) && get(IKEE) == 59)
  51. #define F9_PRESSED          (!get(IKE) && get(IKEE) == 68)
  52. #define ALT_PRESSED         (get(IKCODE) & 8)
  53. #define RET_PRESSED         (getc(KE) == RET)
  54. #define REMOVE_PRESSED      (getc(KE) == getc(REMOVE) )
  55. #define BSPC_PRESSED        (getc(KE) == BSPC)
  56. #define LEFTSHIFT_PRESSED   (get(IKCODE) & 1)
  57. #define RIGHTSHIFT_PRESSED  (get(IKCODE) & 2)
  58. #define SHIFT_PRESSED       (get(IKCODE) & 3)
  59. #define CTRL_PRESSED        (get(IKCODE) & 4)
  60. #define SCROLLLOCK_ACTIVE   (get(IKCODE) & 16)
  61. #define NUMLOCK_ACTIVE      (get(IKCODE) & 32)
  62. #define CAPS_ACTIVE         (get(IKCODE) & 64)
  63. #define INSERT_ACTIVE       (get(IKCODE) & 128)
  64.  
  65. #define LEFTARROW_PRESSED   (!get(IKE) &&  get(IKEE) == 75)
  66. #define RIGHTARROW_PRESSED  (!get(IKE) &&  get(IKEE) == 77)
  67. #define UPARROW_PRESSED     (!get(IKE) &&  get(IKEE) == 72)
  68. #define DOWNARROW_PRESSED   (!get(IKE) &&  get(IKEE) == 80)
  69.  
  70. #define PGUP_PRESSED        (!get(IKE) &&  get(IKEE) == 73)
  71. #define PGDN_PRESSED        (!get(IKE) &&  get(IKEE) == 81)
  72. #define HOME_PRESSED        (!get(IKE) &&  get(IKEE) == 71)
  73. #define END_PRESSED         (!get(IKE) &&  get(IKEE) == 79)
  74. #define CTRLG_PRESSED       (get(IKE) == 7) /* videos grid for testing   */
  75. #define FUNCT_PRESSED       (!get(IKE)  && between(get(IKEE),59,72))
  76.  
  77.  
  78. /****************************************************************************
  79.  *                                                                          *
  80.  *                            keyboard                                      *
  81.  *                                                                          *
  82.  *   Most C programmers are used to 'ch = getch();'                         *
  83.  *                                                                          *
  84.  *   In JJB, just use:    'get_ch();'                                       *
  85.  *                        'get_num();'                                      *
  86.  *                        'get_any();'                                      *
  87.  *                                                                          *
  88.  ****************************************************************************/
  89.  
  90.  
  91.  
  92. /****************************************************************************
  93.  *                                                                          *
  94.  *                              get_ch()                                    *
  95.  *                                                                          *
  96.  *   Use get_ch() instead of getch().                                       *
  97.  *   The reason you must use get_ch() is because JJB needs to look at every *
  98.  *   keypress to see if ALT has been pressed for changing options.          *
  99.  *                                                                          *
  100.  *   also, JJB is designed to execute get_ch() without expecting            *
  101.  *   a return value. Everytime you use get_ch(), JJB does a BIOS            *
  102.  *   read, updating four characters: KE, KEE, KEU & KCODE and four          *
  103.  *   integers: IKE, IKEE, IKEU, and IKCODE.  These values are               *
  104.  *   stored in arrays and are accessible from any object module             *
  105.  *   with the 'get(' and 'set(' functions described in  'JJBSET.H'.         *
  106.  *                                                                          *
  107.  *   Here is an example of how to use:                                      *
  108.  *                                                                          *
  109.  *            get_ch();                                                     *
  110.  *                                                                          *
  111.  *            if (ESC_PRESSED) do_something();                              *
  112.  *                                                                          *
  113.  *   Everytime you use get_ch(), JJB sets in arrays:                        *
  114.  *       KE     is the character of the key you pressed.                    *
  115.  *       KEU    is KE taken to upper case.                                  *
  116.  *       IKE    is the integer of KE. If 'a' is pressed, IKE would be 97.   *
  117.  *       IKEU   is the integer of KEU. If 'a' is pressed, IKEU would be 65  *
  118.  *       KEE    if KE = '\0', then KEE holds the value of the special key.  *
  119.  *       IKEE   is the integer value of KEE.                                *
  120.  *       KCODE  is the keyboard scan code.                                  *
  121.  *       IKCODE is the keyboard scan code taken to an integer value.        *
  122.  *                                                                          *
  123.  *   You may still use 'ch = get_ch()', but it is no longer necessary       *
  124.  *   because JJB handles everything for you. The JJB input and enter        *
  125.  *   functions are designed to be high level functions not requiring        *
  126.  *   low level testing of keypresses. JJB does that for you.                *
  127.  *                                                                          *
  128.  *   There are pluses for you all throughout the JJB system. One of them is *
  129.  *   that at any time, you can press 'CONTROL G' and a grid will be         *
  130.  *   displayed on the screen. You can use the row and column numbers for    *
  131.  *   placing the cursor or videoing text to the screen.                     *
  132.  *                                                                          *
  133.  *    'get_num()' is the same as get_ch()' except that JJB will only allow  *
  134.  *    you to press a number.                                                *
  135.  *                                                                          *
  136.  *    'get_any() will wait for any key to be pressed.                       *
  137.  *                                                                          *
  138.  ****************************************************************************/
  139.  
  140.  
  141. /* miscellaneous definitions */
  142.  
  143. #define T 1                /* T for true                              */
  144. #define beep printf("\a")
  145. #define kk getch()         /* JJB uses this only for debugging only   */
  146. #define BEGIN while(1) {   /* BEGIN....AGAIN is an easy way to see    */
  147. #define AGAIN }            /*    continuous loops                     */
  148. #define DRAWLINE 99        /* use in jjb_setup() to separate options  */
  149.  
  150. #endif
  151.  
  152.  
  153.  
  154.